package com.bclz.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class JdbcUtils {


    private static class JdbcConnection{

        private static final String jdbcDriver="com.mysql.jdbc.Driver";
        private static   String url;
        private static   String userName;
        private static   String password;



        private static Connection con=null;

        static{

            try {
                Properties prop= LoadProperties.loadConfig();
                url=prop.getProperty("mysql.url");
                userName=prop.getProperty("mysql.username");
                password=prop.getProperty("mysql.password");
                Class.forName(jdbcDriver);
                con=DriverManager.getConnection(url,userName,password);
            } catch ( ClassNotFoundException | SQLException e) {
                System.out.println("e = " + e);
            }

        }


        public  static Connection getConnection(){

            return con;
        }


    }

    public static Connection getConnection(){

        return JdbcConnection.getConnection();
    }



}
